<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>机构二维码管理</title>
<#include '/frame/version.html'>
<#include '/frame/manage/include_css.html'>
<#include '/frame/manage/include_js.html'>
<#include '/frame/taglib.html'>
	<script type="text/javascript">

		$(document).ready(function () {
			$("#check_box").click(function () {
				if ($("#check_box").attr("checked")) {
					$(":checkbox").attr("checked", true);
				} else {
					$(":checkbox").attr("checked", false);
				}
			});
			$("#msgSearch").click(function () {
				page(1);
			});
		}); 

		function page(currentPage) {
			var localId = $('#groupid1').find('option:selected').val();
			window.location.href = "admin/qrcode/index?currentPage=" + currentPage + "&orgName=" + $("#orgName").val() + "&status=" + $("#status").val();
		}

		var layerIndex;

		function changeTags(id, type) {
			layerIndex = layer.open({
				type: 2,
				title: '选择标签',
				shadeClose: false,
				shade: 0.8,
				scrollbar: false,
				area: ['380px', '70%'],
				content: '${basePath}/fansUser/tagsTree?type=' + type + '&id=' + id
			});
		}

		function changeTagsBak(url, local, wechat){
			layer.close(layerIndex);
			var index = layer.msg('处理中，请稍后...', {icon: 16,shade: [0.5, '#393D49'],time:0});
			if('' == local && '' == wechat){
				layer.close(index);
				layer.msg("未勾选！");
				return false;
			}
			layer.close(index);
			var keyword = $("#keyword").val();
			console.log(url + '&local=' + local + '&wechat=' + wechat + '&keyword=' + keyword + '&localId=${localId}&currentPage=${currentPage}');

			window.location = url + '&local=' + local + '&wechat=' + wechat + '&keyword=' + keyword + '&localId=${localId}&currentPage=${currentPage}';
		}

			$("#createQrcode").click(function(){
			var ids = document.getElementsByName('fanids');
			var idStr = '';
		for (var i = 0; i < ids.length; i++) {
				if (ids[i].checked) {
					if (idStr == '') {
						idStr += ids[i].value;
					} else {
						idStr += ',' + ids[i].value;
					}
				}
			} 
			$.post("${basePath}/admin/qrcode/mass",{idStr:idStr},function(data){
				data = eval("("+data+")");
				if(data.state==200){
					$this.after('<img src="${basePath}'+data.qrcodeImage+'" style="width:50px;height:50px" id="img_qrcode" />');
					$this.remove();
				}else{
					stem.warn("生成二维码失败");
				}
				stem.close(layIndex);
			}); 
	
		})

		function batchDelBak(idStr, local, wechat){
			layer.close(layerIndex);
			var index = layer.msg('处理中，请稍后...', {icon: 16,shade: [0.5, '#393D49'],time:0});
			if('' == local && '' == wechat){
				layer.close(index);
				layer.msg("未勾选！");
				return false;
			}
			layer.close(index);
			var keyword = $("#keyword").val();

			window.location = '${basePath}/fansUser/batchDel?idStr=' + idStr + '&local=' + local + '&wechat=' + wechat + '&keyword=' + keyword + '&localId=${localId}&currentPage=${currentPage}';
		}



		function batchAddBak(idStr, local, wechat){
			layer.close(layerIndex);
			var index = layer.msg('处理中，请稍后...', {icon: 16,shade: [0.5, '#393D49'],time:0});
			if('' == local && '' == wechat){
				layer.close(index);
				layer.msg("未勾选！");
				return false;
			}
			layer.close(index);
			var keyword = $("#keyword").val();

			window.location = '${basePath}/fansUser/batchAdd?idStr=' + idStr + '&local=' + local + '&wechat=' + wechat + '&keyword=' + keyword + '&localId=${localId}&currentPage=${currentPage}';
		}
		
		function exportExcel(that){
             var $form = $(that).closest("form");
             $form.submit();
        }
		
	</script>
</head>
<body id="nv_member" class="pg_CURMODULE">
	<#assign current='menu_qrcode'>
	<div id="wp" class="wp">
		<#include "/include/header.html"/>
		<!--中间内容-->
		<div class="contentmanage">
			<div class="developer">
				<div class="tableContent">
					<#include "/include/left.html"/>
					<#include "/include/wxtop.html"/>
					<div class="content">
						<div class="cLineB">
				        <h4 class="left">
				        	机构二维码管理
				        </h4>
				        <div class="clr">
				        </div>
							<div class="cLine">
								<!-- <div class=" left">
									 <a class="btnGrayS vm bigbtn" href="${basePath}/fansUser/toUpdate"><img class="vm" src="${basePath}/images/text.png">同步粉丝信息</a>
								</div> -->
								<div class="right">
									 <a class="btnGrayS" href="javascript:;;" id="a_makeqrcode"><img class="vm" src="${basePath}/images/icons/16/add.png">批量生成二维码</a>
								</div>
								<div class="clr"></div>
							</div>
							<div style="border-top: 1px solid #ccc; padding-top: 10px; margin-top: 10px;" class="msgWrap">
								<div style="margin: 5px 0">
									<div class="left">
											<input type="text" value="${orgName?default('')}" name="orgName" id="orgName" placeholder="输入机构名称搜索" class="px" />
<!-- 											<input type="text" value="${status?default('')}" name="status" id="status" placeholder="输入是否生成二维码搜索" class="px"  />
 -->											<input type="button" title="搜索" class="btnGrayS" id="msgSearch" value="搜索" />
									</div>
									<div class="searchbar right">
									        <form action="${basePath}/admin/qrcode/export" method="post" target="_self">
									        	
									           <select name="flag">
									               <option value="0">导出当前页</option>
									               <option value="1">导出全部</option>
									           </select>
									           <a class="btnGrayS" href='javascript:void(0)' onclick="exportExcel(this)" onfocus="this.blur;">
									               <img class="vm" height="20" width="20" src="${basePath}/images/export-32.png"/>&nbsp;&nbsp;导出
									           </a>
									          <input type="hidden" name="currentPage" value="${page.currentPage}"/>
									          <input type="hidden" name="nickname" value="${keyword}"/>
									          <input type="hidden" name="phone" value="${phone}"/>
									          <input type="hidden" name="userName" value="${userName}"/>
									          <input type="hidden" name="wxid" value="${wxid}"/>
									           
									       </form>
									     </div>
									     
									
									
										<div style="clear: both"></div>

								</div>
								<table class="ListProduct Shallow_border_color" border="0"
								cellSpacing="0" cellPadding="0" width="100%">
									<thead>
									<tr>
										<th class="select"><input type="checkbox" id="check_box"></th>
										<th>机构名称</th>
										<th>机构二维码</th>
									</tr>
									</thead>
									<tbody>
										<#if page?exists>
										<#list page.recordList as bean >
											<tr>
												<td><input type="checkbox" name="fanids" id="fanids" class="cbitem" value="${bean.id}"></td>
												<td>${bean.orgName?default('')}</td>
												<td><#if bean.qrcodeUrl!=null&&bean.qrcodeUrl!=''><img class="img_qrcode" height="30" width="30" src="${bean.qrcodeUrl?default('')}"> </#if></td>
											</tr>
										</#list>
										</#if>
									</tbody>
								</table>
							</from>
							</div>
						<#include "/include/form_pagination.html"/>
					</div>
					<div class="clr"></div>
				</div>
			</div>
		</div>
		<!--底部-->
	</div>
	<#include "/include/footer.html"/>
	

	<script>
	$(".img_qrcode").on("click",function(){
		
			layer.open({
			    type: 1,
			    area: ['400px', '400px'],
			    title: false,
			    skin: 'layui-layer-nobg',
			    shadeClose: true,
			    content: '<p style="text-align: center;"><img src="'+$(this).attr("src")+'" alt="无法显示图片" style="width:100%;height:100%;" /></p>'
			});
		});
		$("#a_makeqrcode").on("click",function(){
		
		var ids = document.getElementsByName('fanids');
		var idStr = '';
		for (var i = 0; i < ids.length; i++) {
				if (ids[i].checked) {
					if (idStr == '') {
						idStr += ids[i].value;
					} else {
						idStr += ',' + ids[i].value;
					}
				}
			} 
		 location.href="${basePath}/admin/qrcode/mass?idStr="+idStr;
		/* 	var $this = $(this);
			var layIndex = stem.loading();
				$.post("${basePath}/admin/qrcode/mass",{idStr:idStr},function(data){
				data = eval("("+data+")");
				if(data.state==200){
					$this.after('<img src="${basePath}'+data.qrcodeImage+'" style="width:50px;height:50px" id="img_qrcode" />');
					$this.remove();
				}else{
					stem.warn("生成二维码失败");
				}
				stem.close(layIndex);
			}); */
		});
	</script>
</body>
</html>